#ifndef JEGEO_PREDICATE_HPP
#define JEGEO_PREDICATE_HPP

#include "jegeo/model.hpp"
#include "jegeo/math.hpp"

namespace jegeo {
namespace jemath = jegeo::math;

namespace overlap{
/*
* 判断点是否在矩形边上
*/
template<typename T>
bool point_on_rect(const Point<T> &point, const Rect<T> &rect, const T& epsilon = jemath::Epsilon<T>()) {
    int ori = jemath::orientation_rect2point<T>(jegeo::px1(rect), jegeo::py1(rect), jegeo::px2(rect), jegeo::py2(rect), jegeo::px(point), jegeo::py(point), epsilon);
    return ori == 0;
}


} // namespace overlap


namespace contains {
template<typename T>
bool point_in_rect(const Point<T> &point, const Rect<T> &rect, bool consider_touch = true, const T& epsilon = jemath::Epsilon<T>()) {
    return jemath::contains_point_in_rect<T>(jegeo::px(point), jegeo::py(point), jegeo::px1(rect), jegeo::py1(rect), jegeo::px2(rect), jegeo::py2(rect), consider_touch, epsilon);
}

} // namespace contains


namespace intersects {
template<typename T>
bool rect2rect(const Rect<T> &rect1, const Rect<T> &rect2, bool consider_touch = true, const T& epsilon = jemath::Epsilon<T>()) {
    return jemath::intersects_rect2rect<T>(jegeo::px1(rect1), jegeo::py1(rect1), jegeo::px2(rect1), jegeo::py2(rect1), jegeo::px1(rect2), jegeo::py1(rect2), jegeo::px2(rect2), jegeo::py2(rect2), consider_touch, epsilon);
}

} // namespace intersects


namespace distance {
template<typename T>
T point2rect(const Point<T> &point, const Rect<T> &rect) {
    return jemath::distance_point2rect<T>(jegeo::px(point), jegeo::py(point), jegeo::px1(rect), jegeo::py1(rect), jegeo::px2(rect), jegeo::py2(rect));
}

} // namespace distance

namespace intersection {

}



} // namespace jegeo



#endif // JEGEO_PREDICATE_HPP
